package cn.panda.edu.service.impl;

import cn.panda.edu.dao.ThesisMapper;
import cn.panda.edu.model.Thesis;
import cn.panda.edu.service.ThesisService;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 
 * 类描述：  论文
 */
@Service
public class ThesisServiceImpl implements ThesisService {
	@Autowired
    ThesisMapper thesisMapper;
	@Override
	public int deleteByPrimaryKey(Integer thesisId) {
		// TODO Auto-generated method stub
		return thesisMapper.deleteByPrimaryKey(thesisId);
	}

	@Override
	public int insert(Thesis record) {
		// TODO Auto-generated method stub
		return thesisMapper.insert(record);
	}

	@Override
	public int insertSelective(Thesis record) {
		// TODO Auto-generated method stub
		return thesisMapper.insertSelective(record);
	}

	@Override
	public Thesis selectByPrimaryKey(Integer thesisId) {
		// TODO Auto-generated method stub
		return thesisMapper.selectByPrimaryKey(thesisId);
	}

	@Override
	public int updateByPrimaryKeySelective(Thesis record) {
		// TODO Auto-generated method stub
		return thesisMapper.updateByPrimaryKeySelective(record);
	}
	@Override
	public PageInfo<Thesis> listAll(int pageIndex , int pageSize, Thesis record) {
		// TODO Auto-generated method stub
		Page<Thesis> plist = PageHelper.startPage(pageIndex, pageSize);
		thesisMapper.listAll(record);
		return new PageInfo<>(plist);
	}
	@Override
	public PageInfo<Thesis> listAllByStuId(Integer stuId, int pageIndex , int pageSize) {
		// TODO Auto-generated method stub
		Page<Thesis> plist = PageHelper.startPage(pageIndex, pageSize);
		thesisMapper.listAllByStuId(stuId);
		return new PageInfo<>(plist);
	}
	@Override
	public int updateByPrimaryKey(Thesis record) {
		// TODO Auto-generated method stub
		return thesisMapper.updateByPrimaryKey(record);
	}

	@Override
	public PageInfo<Thesis> selectLikeByPageSelective(Integer studentId, String studentName, Integer pageIndex,
                                                      Integer pageSize) {
		Map<String, Object> map = new HashMap<String,Object>();
		map.put("studentId", studentId);
		map.put("studentName", studentName);
		PageHelper.startPage(pageIndex, pageSize);
		List<Thesis> tList = thesisMapper.selectLikeByPageSelective(map);
		PageInfo<Thesis> pageInfo = new PageInfo<>(tList);
		return pageInfo;
	}

	
}
